import request from "@/utils/request";
import { ManagerPageVO, MannagerQuery, ManagerForm } from "./types";
import { AxiosPromise } from "axios";

/**
 * 获取用户分页列表
 *
 * @param queryParams
 */
export function getManagerPage(
  queryParams: MannagerQuery
): AxiosPromise<PageResult<ManagerPageVO[]>> {
  return request({
    url: "/api/admin/page",
    method: "get",
    params: queryParams,
  });
}

/**
 * 获取用户表单详情
 *
 * @param userId
 */
export function getUserForm(userId: string): AxiosPromise<ManagerForm> {
  return request({
    url: "/api/admin/" + userId,
    method: "get",
  });
}

/**
 * 修改管理员信息
 * @param name
 * @param data
 */
export function manEditListData(data: any, name: string) {
  return request({
    url: "/api/admin/update?name=" + name,
    method: "put",
    data: {
      id: data.id,
      deptId: data.deptId,
      name: data.name,
      phone: data.phone,
      position: data.position,
      roleId: data.roleId,
      status: data.status,
      username: data.username,
    },
  });
}

/**
 * 添加管理员信息
 * @param data
 */
export function manAddListData(data: any) {
  return request({
    url: "/oauth/register",
    method: "post",
    data: data,
  });
}

/**
 * 删除管理员信息
 */
export function manDelistData(id: string) {
  return request({
    url: "/api/admin/delete",
    method: "delete",
    data: {
      id: id,
    },
  });
}

/**
 * 修改用户密码
 *
 * @param id
 *
 */
export function updateManagerPassword(id: string) {
  return request({
    url: "/api/admin/update/" + id,
    method: "put",
  });
}
